﻿CREATE TABLE [dbo].[DETALLE_PARTIDA](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[IdPartida] [int] NOT NULL,
	[IdFuenteFinanciera] [int] NOT NULL,
	[MontoAsignado] [decimal](18, 2) NOT NULL,
	[MontoGastado] [decimal](18, 2) NOT NULL,
	[Saldo] [decimal](18, 2) NOT NULL,
 CONSTRAINT [PK_dbo.DETALLE_PARTIDA] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  ForeignKey [FK_dbo.DETALLE_PARTIDA_dbo.FUENTE_FINANCIERA_IdFuenteFinanciera]    Script Date: 11/17/2014 00:41:42 ******/
ALTER TABLE [dbo].[DETALLE_PARTIDA]  WITH CHECK ADD  CONSTRAINT [FK_dbo.DETALLE_PARTIDA_dbo.FUENTE_FINANCIERA_IdFuenteFinanciera] FOREIGN KEY([IdFuenteFinanciera])
REFERENCES [dbo].[FUENTE_FINANCIERA] ([Id])
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[DETALLE_PARTIDA] CHECK CONSTRAINT [FK_dbo.DETALLE_PARTIDA_dbo.FUENTE_FINANCIERA_IdFuenteFinanciera]
GO
/****** Object:  ForeignKey [FK_dbo.DETALLE_PARTIDA_dbo.PARTIDA_IdPartida]    Script Date: 11/17/2014 00:41:42 ******/
ALTER TABLE [dbo].[DETALLE_PARTIDA]  WITH CHECK ADD  CONSTRAINT [FK_dbo.DETALLE_PARTIDA_dbo.PARTIDA_IdPartida] FOREIGN KEY([IdPartida])
REFERENCES [dbo].[PARTIDA] ([Id])
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[DETALLE_PARTIDA] CHECK CONSTRAINT [FK_dbo.DETALLE_PARTIDA_dbo.PARTIDA_IdPartida]
GO
CREATE NONCLUSTERED INDEX [IX_IdFuenteFinanciera] ON [dbo].[DETALLE_PARTIDA] 
(
	[IdFuenteFinanciera] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_IdPartida] ON [dbo].[DETALLE_PARTIDA] 
(
	[IdPartida] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]